package com.ms.controller;
import com.ms.common.Result;
import com.ms.pojo.Admin;
import com.ms.service.AdminService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/admin")
@Tag(name = "管理员接口")
public class AdminController {

    @Autowired
    private AdminService adminService;
    @PostMapping  ("/login")
    @Operation(summary = "管理员登录接口")
        public Result<Admin> login(String admin_username, String admin_password) {
            Admin admin = adminService.adminlogin(admin_username, admin_password);
            if (admin != null) {
                // 登录成功，返回用户信息
                return Result.success(admin);
            } else {
                // 登录失败，返回错误信息
                return Result.error("用户名或密码错误");
            }
        }

    }

